package base

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type Base struct{}

type standard struct {
	Code  int         `json:"code"`
	Msg   string      `json:"msg"`
	Data  interface{} `json:"data"`
}

func Success(c *gin.Context, msg string, data interface{}) {
	c.JSON(http.StatusOK, standard{Code: 0, Msg: msg, Data: data})
}

func Error(c *gin.Context, msg string, data interface{}) {
	c.JSON(http.StatusOK, standard{Code: 500, Msg: msg, Data: data})
}

func Html(c *gin.Context, template string, data interface{}) {
	c.HTML(http.StatusOK, template, data)
}

func Redirect(c *gin.Context, code int, location string) {
	c.Redirect(code, location)
}
